package com.lc.rongzecaifu.view;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.facebook.drawee.view.SimpleDraweeView;
import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.conn.JsonIndex;
import com.lc.rongzecaifu.rongzecaifu.R;

import java.util.List;

/**
 * @author http://blog.csdn.net/finddreams
 * @Description:gridview的Adapter
 */
public class MyGridAdapter extends BaseAdapter {
    private Context mContext;
    private List<JsonIndex.Info.Linek_img> list;
    public String[] img_text = {"投资管理", "我的礼券", "我的资产", "债权管理", "邀请好友", "银行卡管理",
            "密码设置","",""};
    public int[] imgs = {R.mipmap.ic_launcher, R.mipmap.ic_launcher,
            R.mipmap.ic_launcher, R.mipmap.ic_launcher,
            R.mipmap.ic_launcher, R.mipmap.ic_launcher,
            R.mipmap.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher};

    public MyGridAdapter(Context mContext, List<JsonIndex.Info.Linek_img> list) {
        super();
        this.mContext = mContext;
        this.list=list;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        MyGridAdapter.ViewHolder viewHolder;

        if (convertView == null) {

      convertView = MyApplication.scaleScreenHelper.loadView((ViewGroup)LayoutInflater.from(mContext).inflate(R.layout.item_icon, null));
        //    convertView= MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.item_icon),null);
//            MyApplication.scaleScreenHelper.loadView((ViewGroup) convertView);

            viewHolder = new MyGridAdapter.ViewHolder();
            viewHolder.img_icon = (SimpleDraweeView) convertView.findViewById(R.id.img_icon);
            viewHolder.img_icon.setImageURI(Uri.parse(list.get(position).link_img));
            convertView.setTag(viewHolder);

        } else {

            viewHolder = (MyGridAdapter.ViewHolder) convertView.getTag();

        }



        return convertView;

    }
    private class ViewHolder {
        SimpleDraweeView img_icon;




    }
}
